package com.xiaoshuidi.cloud.module.rooms.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 预定退定状态枚举
 * @author Joey
 */
@Getter
@AllArgsConstructor
public enum ReserveWithdrawStatusEnum {
    /**
     * 待退款
     */
    PENDING("pending","待退款"),
    /**
     * 已退款
     */
    REFUNDED("refunded","已退款")
    ;
    private String value;
    private String name;

    public static String getValueByName(String name) {
        ReserveWithdrawStatusEnum resonEnum = Arrays.stream(ReserveWithdrawStatusEnum.values()).filter(p -> p.name.equals(name)).findFirst().orElse(null);
        Assert.isTrue(resonEnum != null,"ReserveWithdrawStatusEnum类型:{}不存在",name);
        return resonEnum.getValue();
    }

    public static String getNameByValue(String value) {
        ReserveWithdrawStatusEnum resonEnum = Arrays.stream(ReserveWithdrawStatusEnum.values()).filter(p -> p.value.equals(value)).findFirst().orElse(null);
        Assert.isTrue(resonEnum != null,"ReserveWithdrawStatusEnum类型:{}不存在",value);
        return resonEnum.getName();
    }

}
